﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace MyBlog2.Models
{
    public class Article
    {
        public Article()
        {
            this.ArticleComment = new HashSet<Comment>();
            this.ArticleTag = new HashSet<ArticleTag>();
        }

        [Key]
        public int Id { get; set; }

        [Display(Name = "分类id")]
        [Required(ErrorMessage = "{0}不能为空")]
        public int ArticleClassifyId { get; set; }


        [Display(Name = "文章标题")]
        [Required(ErrorMessage = "{0}不能为空")]
        [StringLength(200, ErrorMessage = "{0}不能超过100字")]
        public string Title { get; set; }


        [Display(Name = "文章简介")]
        [StringLength(200, ErrorMessage = "{0}不能超过100字")]
        public string Description { get; set; }


        [Display(Name = "文章内容")]
        [Required(ErrorMessage = "{0}不能为空")]
        [DataType(DataType.MultilineText)]
        public string Contents { get; set; }


        [Required(ErrorMessage = "{0}不能为空")]
        [Display(Name = "标识")]
        public string Flag { get; set; }


        [Display(Name = "浏览次数")]
        public int Views { get; set; }


        [Display(Name = "开启声明")]
        public bool ShareStatement { get; set; }    //转载申明是否开启


        [Display(Name = "开启评论")]
        public bool CommentAbled { get; set; }      //评论是否显示


        [Display(Name = "是否发布")]
        public bool Published { get; set; }


        [Display(Name = "创建时间")]
        [DataType(DataType.DateTime)]
        public DateTime CreateTime { get; set; }


        [Display(Name = "更新时间")]
        [DataType(DataType.DateTime)]
        public DateTime UpdateTime { get; set; }

        [Required]
        public string TagIds { get; set; }      //标签id集合

        //[Required]
        //public string UserId { get; set; }

        public User User { get; set; }      //关联账户

        public virtual ArticleClassify ArticleClassify { get; set; }    //关联分类


        public virtual ICollection<ArticleTag> ArticleTag { get; set; }      //关联

        public virtual ICollection<Comment> ArticleComment { get; set; }    //关联评论


    }

    
}
